Skip to content

feat(core): Add API to clear scope feature flags#5426

Open
adinauer wants to merge 2 commits into
mainfrom
feat/clear-scope-feature-flags
Open

feat(core): Add API to clear scope feature flags#5426
adinauer wants to merge 2 commits into
mainfrom
feat/clear-scope-feature-flags

Conversation

@adinauer
Copy link
Copy Markdown
Member

📜 Description

Add IScope.clearFeatureFlags() to clear feature flag evaluations stored on a scope.

This also makes Scope.clear() reset the feature flag buffer, matching the existing expectation that clearing a scope returns it to its default state.

💡 Motivation and Context

Fixes #5422
Refs JAVA-512

Previously, feature flag evaluations could only be added or overwritten by name. There was no way to remove evaluations that no longer apply, which could leave stale feature flags attached to later error events after an app account switch.

💚 How did you test it?

  • ./gradlew :sentry:test --tests 'io.sentry.ScopeTest' --tests 'io.sentry.featureflags.FeatureFlagBufferTest' --tests 'io.sentry.featureflags.SpanFeatureFlagBufferTest'
  • ./gradlew spotlessApply apiDump

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Docs can be updated separately if we want to document the new scope-level clearing API.

Allow feature flags stored on a scope to be cleared without resetting other scope data. Scope.clear now also resets the feature flag buffer so stale flag evaluations do not carry over after clearing a scope.

Fixes #5422

Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 13, 2026

JAVA-512

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 1296c9f

@sentry
Copy link
Copy Markdown

sentry Bot commented May 13, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.41.0 (1) release

⚙️ sentry-android Build Distribution Settings

@adinauer adinauer marked this pull request as ready for review May 13, 2026 07:55
@github-actions
Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 317.27 ms 340.65 ms 23.38 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
319f256 317.53 ms 370.83 ms 53.29 ms
ab8a72d 316.24 ms 356.38 ms 40.14 ms
cf708bd 434.73 ms 502.96 ms 68.22 ms
91bb874 310.68 ms 359.24 ms 48.56 ms
f634d01 375.06 ms 420.04 ms 44.98 ms
62b579c 299.75 ms 364.84 ms 65.09 ms
6b019b7 403.90 ms 546.09 ms 142.19 ms
d364ace 384.53 ms 453.51 ms 68.98 ms
5b66efd 308.67 ms 363.85 ms 55.18 ms
ee35ac3 346.83 ms 435.48 ms 88.65 ms

App size

Revision Plain With Sentry Diff
319f256 1.58 MiB 2.19 MiB 619.79 KiB
ab8a72d 1.58 MiB 2.12 MiB 551.55 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
91bb874 1.58 MiB 2.13 MiB 559.07 KiB
f634d01 1.58 MiB 2.10 MiB 533.40 KiB
62b579c 0 B 0 B 0 B
6b019b7 0 B 0 B 0 B
d364ace 1.58 MiB 2.11 MiB 539.75 KiB
5b66efd 1.58 MiB 2.13 MiB 559.07 KiB
ee35ac3 1.58 MiB 2.13 MiB 558.77 KiB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add API to clear feature flag buffer

1 participant